/**
采购商的首页待办事项
*/
define(["jquery","knockout","baseview","common"],function($,ko,BaseView,Common){
	var view = BaseView.extend({
		setTemplate:function(option) {
		},
		bindEvents:function() {
		},
		fireEvents:function() {
            this.app.serverEvent().addDataTable("quotEntityDataTable").fire({
                url: "/yuncai/evt/dispatch",
                ctrl: 'portal.BuyofferController',
                method: 'loadData',
                success: function (data) {
                    this.fillStatistic(data);
                }.bind(this)
            })
        },
        viewmodel:{
            el:"#putodo",
            quotEntityDataTable: new $.DataTable({
                params: {
                    "cls": "com.yonyou.ipu.entity.quotation.IpuQuotation"
                },
                meta: {
                    'id': {},
                    'btax': {},
                    'corpAccount': {},
                    'corpAccountid': {},
                    'corpSubAccount': {},
                    'corpSubAccountid': {},
                    'createtime': {type: 'date'},
                    'currencyCode': {},
                    'currencyid': {},
                    'description': {},
                    'erpProductVersion': {},
                    'erpVender': {},
                    'prid': {},
                    'processTime': {type: 'date'},
                    'processor': {},
                    'qtexpiredate': {type: 'date'},
                    'status': {},
                    'subject': {},
                    'ecbillcode': {},
                    'contact': {},
                    'phone': {},
                    'statusName': {},
                    'qtoffersSuppierName':{},
                    'buyofferTime': {type: 'date'},
                },
                pageSize: 10
            }),
            unpublicBillCount: ko.observable(0),
            buyofferpostedBillCount: ko.observable(0),           
            supplyrecommendBillCount: ko.observable(0),           
            pricedecisionedBillCount: ko.observable(0)
        },
        fillStatistic: function(data) {
            var jsonObj = JSON.parse(data);           
            this.viewmodel.unpublicBillCount((jsonObj["13"] ? jsonObj["13"]["count"] : 0)
                + (jsonObj["17"] ? jsonObj["17"]["count"] : 0));
            this.viewmodel.buyofferpostedBillCount(jsonObj["buyofferposted"] ? jsonObj["buyofferposted"]["count"] : 0);
            this.viewmodel.supplyrecommendBillCount(jsonObj["18"] ? jsonObj["18"]["count"] : 0);
            this.viewmodel.pricedecisionedBillCount(jsonObj["15"] ? jsonObj["15"]["count"] : 0);
        }
	});
	return view;
});
